@extends('back_end.layouts.default_info')

{{-- Web site Title --}}
@section('title')
{{{ Lang::get('general.back_end.member').Lang::get('general.index') }}} :: @parent
@stop
@section('content_header')
{{{ Lang::get('general.back_end.member').Lang::get('general.index') }}}
@stop
{{-- breadcrumb --}}
@section('breadcrumb')
<li><a href="#"><i class="fa fa-dashboard"></i> {{{ Lang::get('general.back_end.home') }}}</a></li>
<li class="active">{{{ Lang::get('general.back_end.member').Lang::get('general.index') }}}</li>
@stop
{{-- Content --}}
@section('content')

<div class="box box-primary">
  <div class="box-header" style="cursor: move;">
    <i class="ion ion-clipboard"></i>

    <h3 class="box-title"></h3>

    <div class="box-tools pull-right">
      <?php echo $entries->links(); ?>
    </div>
  </div>
  <!-- /.box-header -->
  <div class="box-body">
    <ul class="todo-list ui-sortable">
      <table class="table table-hover">
        <tbody><tr>
          <th class="col-xs-2">用户名</th>
          <th class="col-xs-2">{{ Form::orderLink($links, '昵称', 'nick_name') }}</th>
          <th class="col-xs-2">Email</th>
          <th class="col-xs-1">角色</th>
          <th class="col-xs-1">状态</th>
          <th class="col-xs-2">{{ Form::orderLink($links, '最近更新', 'updated_at') }}</th>
          <th class="col-xs-3">{{{ Lang::get('table.actions') }}}</th>
        </tr>
        @foreach ($entries as $entry)
        <tr>
          <th class="col-xs-2">{{ $entry->user->username }}</th>
          <th class="col-xs-2">{{ $entry->nick_name }}</th>
          <th class="col-xs-2">{{ $entry->user->email }}</th>
          <th class="col-xs-1">{{ is_array($entry->user->getRoleNamesArray())?implode(", ", $entry->user->getRoleNamesArray()):'' }}</th>
          <th class="col-xs-1">{{ $entry->user->confirmed==1?'已激活':'未激活' }}</th>
          <th class="col-xs-2">{{ $entry->updated_at }}</th>
          <th class="col-xs-3">
            @if (Auth::user()->can('update_member'))
              <a href="{{{ URL::action('BackMemberController@doUpdate', $entry->id) }}}" class="iframe btn btn-xs btn-default"><i class="fa fa-edit"></i> {{{ Lang::get('button.edit') }}}</a>
            @elseif (Auth::user()->can('show_member'))
              <a href="{{{ URL::action('BackMemberController@doUpdate', $entry->id) }}}" class="iframe btn btn-xs btn-default"><i class="fa fa-eye"></i> {{{ Lang::get('button.view') }}}</a>
            @endif
            @if (Auth::user()->can('delete_member'))
              <a href="#deleteModal" data-id="{{ $entry->id }}" data-toggle="modal" class="iframe btn btn-xs btn-danger"><i class="fa fa-trash-o"></i> {{{ Lang::get('button.delete') }}}</a>
            @endif
          </th>
        </tr>
        @endforeach
        </tbody></table>

    </ul>
  </div>
  <!-- /.box-body -->
  <div class="box-footer clearfix no-border">
      @if (Auth::user()->can('create_member'))
    <a href="{{{ URL::to('back_end/members/create') }}}" class="btn btn-default pull-right"><i class="fa fa-plus"></i><i class="icon-plus-sign"></i> {{{ Lang::get('button.create') }}}</a>
    @endif
  </div>
</div>

<!-- Modal -->
<div id="deleteModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">确认删除</h3>
      </div>
      <div class="modal-body">
        <p>确认删除这条信息?</p>
      </div>
      <div class="modal-footer">
        <form id="deleteForm" class="form-horizontal" method="post" action="" autocomplete="off">
          <!-- CSRF Token -->
          <input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
          <input type="hidden" name="id" value="" />
          <button class="btn" data-dismiss="modal" aria-hidden="true">{{{ Lang::get('button.cancel') }}}</button>
          <button type="submit" class="btn btn-primary">{{{ Lang::get('button.ok') }}}</button>
        </form>
      </div>
    </div>
  </div>
</div>
<!-- Modal End -->
@stop

{{-- Scripts --}}
@section('scripts')
<script type="text/javascript">
  var deleteAction = "{{ URL::to('back_end/members/delete') }}";
  $('a[data-toggle="modal"]').click(function(){
    if(deleteAction){
      $('form#deleteForm').attr('action',  deleteAction + '/' + $(this).attr('data-id'));
      $('form#deleteForm input[name="id"]').attr('value',  $(this).attr('data-id'));
    }
  });
</script>
@stop
